var orderdb = require('../../db/order.db')
var config = require('../../config')
var emit = require('../../emit')
var async = require('async')

function onsocket(socket,data){            
    async.forEach(data.ids,(id,cb) =>{
        orderdb.removecartitem(socket.handshake.cookies.authorized, id,function(err){            
            cb(err);            
        });
    },(err) =>{
        if(config.debug){
            logger.log(err);
        }
        else{
            if(err){
                emit.send(socket,'removecartitem', 0);
            }else{
                emit.send(socket,'removecartitem', 1);
            }
        }
    })            
}

module.exports = {
    onsocket
}